/*
1. Load coverage effect (45-64, notall16) by state
2. Determine states below/above median coverage effect
3. Save dataset with state_num and indicator for above median coverage_effect
*/

clear all
set more off
set matsize 11000
set emptycells drop
set scheme s2mono	

global path "****"
global output "****"

cd "$path"

clear all
mat drop _all
estimates clear

set obs 51
gen state_num = _n


forval state = 1/51{
	estimates use "$path/Estimates/cov_state_3_031720", number(`state')
	mat covered1718 = nullmat(covered1718) \ (_b[treatment] , e(N))
}

svmat covered1718

rename covered17181 cov_effect
rename covered17182 count

summ cov_effect [fw = count], de

gen above_med_cov_effect = (cov_effect > r(p50))

keep state_num above_med_cov_effect

save "$output/state_cov_effect_050520.dta", replace
